<!-- #include virtual="/components_cb/client/initDialogEnv_tagged.inc"-->
<!--<%'-------------------------- Server side includes -------------------------%>-->
<!-- #include virtual='/components_cb/server/controls.inc' -->
<html>
<head>
    <title>OneSite</title>
    <script type="text/javascript" src="/components_cb/client/scriptinc_js.htm"></script>
    <script type="text/javascript" src="/components_cb/client/scriptinc_nocache_js.htm"></script>
    <script type="text/javascript" src="/components_cb/client/htmlstart.min.js"></script>
    <script type="text/javascript" src="/documentmanagement/common_cb.js"></script>
    <link rel="stylesheet" type="text/css" href="/components_cb/styles/base.min.css" />
    <link rel="stylesheet" type="text/css" href="/components_cb/styles/form.min.css" />
    <link rel="stylesheet" type="text/css" href="/components_cb/styles/supertable.min.css" />
    <script type="text/javascript">
        //var top = window.dialogArguments;
        window.returnValue = false;
        //window.dialogHeight = "400px";
        //window.dialogWidth = "450px";
        //window.resizeTo(380, 350);
    </script>
    <script type="text/javascript">
        var xmlProperties = NewXmlDOM(false);
        var xmlPropertiesOrg = NewXmlDOM(false);
        var xmlCabinetDocumentType = NewXmlDOM(false);
        var xmlControls_WATCH_Initialize = NewXmlDOM(false);    
    </script>
    <script type="text/javascript">
        var pageStage = '';
        function InitialLoad_Start()
        {
            var sXML;
            otblProperties = $('#tblProperties').data('ST');
            sXML = "<Page><Request ";
            if (!isNull(top.GetPSCurrent("DOCUMENTTYPEID")) && parseInt(top.GetPSCurrent("DOCUMENTTYPEID"), 10) > 0)
            {
                sXML += "DocumentTypeID='" + top.GetPSCurrent("DOCUMENTTYPEID") + "' ";
            }
            else
            {
                sXML += "DocumentTypeID='" + '' + "' ";
            }
            sXML += "/></Page>";
            InitialLoad_GetData("", top.ShellAddress + "DocumentManagement/ASPX/DocumentType.aspx/GetDocumentTypePropertyInitial", sXML);
        }

        function InitialLoad_onDataReady()
        {
            InitialLoad_FillXML("Properties", "xmlProperties", "xmlPropertiesOrg");
            InitialLoad_FillXML("CabinetDocumentType", "xmlCabinetDocumentType", "");
        }
        function checkSaveButton()
        {
            var nodes;
            nodes = $(xmlProperties).find("Row");
            if ($(nodes).length > 0)
            {
                Button_Enable($('#<%=pageprefix%>btnPush'));
                Button_Enable($('#<%=pageprefix%>btnPushLabel'));
                $("#btnPush").attr("title", "Push to properties");
            }
            else
            {
                Button_Disable($('#<%=pageprefix%>btnPush'));
                Button_Disable($('#<%=pageprefix%>btnPushLabel'));
                $("#btnPush").attr("title", "There is no property listed");
            }
        }
        function Initialize()
        {
            var row;
            rpiModalHeader.setLoadIndicator(false);
            row = $(xmlCabinetDocumentType).find("Row").eq(0);
            if ($(row).length > 0)
            {
                rpiModalHeader.setPageLabel($(row).attr("Type"));
            }
            else
            {
                rpiModalHeader.setPageLabel("");
            }

            if ($(xmlProperties).find("Row[Selected='1']").length === $(xmlProperties).find("Row").length)
            {
                $("#chkSelectAll").prop("checked", true);
            }
            otblProperties.updateTable();
            checkSaveButton();
            if ($.browser.mozilla)
            {
                window.resizeTo(parseInt(window.dialogWidth, 10), parseInt(window.dialogHeight, 10) + 65);
                $("#applyCheckBox").find("div.RPI_WATCH").css("display", "");
                $("#tblModalHeader").css("width", "100%");
                $("#tdModalHeader").css("width", "300px");
                $("#tdMHBtnWidth").css("width", "18px");
            }
            else if ($.browser.safari)
            {
                window.resizeTo(parseInt(window.dialogWidth, 10), parseInt(window.dialogHeight, 10) + 40);
                $("#applyCheckBox").find("div.RPI_WATCH").css("display", "");
                $("#tblModalHeader").css("width", "100%");
                $("#tdModalHeader").css("width", "300px");
                $("#tdMHBtnWidth").css("width", "18px");
            }

            else if ($.browser.chrome)
            {
                window.resizeTo(parseInt(window.dialogWidth, 10), parseInt(window.dialogHeight, 10) + 40);
                $("#applyCheckBox").find("div.RPI_WATCH").css("display", "");
                $("#tblModalHeader").css("width", "100%");
                $("#tdModalHeader").css("width", "300px");
                $("#tdMHBtnWidth").css("width", "18px");
            }
        }
        function InitialLoad_onComplete()
        {
            Controls_Initialize();
            Initialize();
            Controls_WATCH_Initialize();
            xmlControls_WATCH_Initialize.async = false;
            xmlControls_WATCH_Initialize.loadXML("<Row a='1' />");
            StoreDataXml("xmlControls_WATCH_Initialize", xmlControls_WATCH_Initialize);
            otblProperties.updateTable();
            top.resizeDialog(bUsingIframe);
            top.setCustomDialogSize(480, 380);
            top.setActionButtonsPosition(0, 0, window);

        }

        function afterBinding()
        {
            Controls_WATCH_Initialize();
            Initialize();
        }

        function doCancel()
        {
            window.returnValue = false;
            //window.close();
            top.hideDialog(window.returnValue, window, bUsingIframe);
        }

        function doToggleSelectAll()
        {
            var oNodes, oElements, i;
            oNodes = $(xmlProperties).find("Row");
            for (i = 0; i < $(oNodes).length; i++)
            {
                $(oNodes[i]).attr("Selected", $("#chkSelectAll").prop("checked") ? "1" : "0");
            }
            oElements = $(document).find($("input:checkbox[name='chkSelected']"));
            for (i = 0; i < $(oElements).length > 0; i++)
            {
                $(oElements[i]).prop("checked", $("#chkSelectAll").prop("checked") ? true : false);
            }
            checkSaveButton();
        }


        $(document).ready(function ()
        {
            $("#tblProperties").mouseover(function (event)
            {
                if ($(event.target)[0].nodeName.toUpperCase().toString() === "TH" && $(event.target).attr("class").toString() === "center sorting")
                {
                    $(event.target).css({ 'background': '#686fa1' });
                    $(event.target).css({ 'color': '#FFFFFF' });
                    $(event.target).mouseleave(function ()
                    {
                        $(event.target).css({ 'background': '#3366cc' });
                    });
                }
            });
        });

        function doToggleSelected()
        {
            var oRow, checked, oNode;
            oRow = otblProperties.getClickedRow();
            checked = otblProperties.getSelectedCheckboxStatus();
            oNode = $(xmlProperties).find("Row[SiteID='" + $(oRow).attr("SiteID") + "']").eq(0);
            $(oNode).attr("Selected", checked ? "1" : "0");
            if ($(xmlProperties).find("Row[Selected='1']").length === $(xmlProperties).find("Row").length)
            {
                $("#chkSelectAll").prop("checked", true);
            }
            else
            {
                $("#chkSelectAll").prop("checked", false);
            }
            checkSaveButton();
        }

        function Push_Initialize()
        {
            rpiModalHeader.setLoadIndicator(true);
            window.setTimeout("Push()", 1);
        }

        function Push()
        {
            var docType, applyRetPolicyToExistingDocs, sXML, result;
            docType = top.GetPSCurrent("DOCUMENTTYPEID");
            applyRetPolicyToExistingDocs = 'false';
            if ($("#chkApplyToExistingDocs").prop("checked"))
            {
                applyRetPolicyToExistingDocs = 'true';
            }
            sXML = "<Page><Request DocumentType='" + docType + "' applyRetPolicyToExistingDocs='" + applyRetPolicyToExistingDocs + "' />" + $(xmlProperties)[0].xml + "</Page>";
            result = top.objHTMUtils.NewPost("", top.ShellAddress + "documentmanagement/ASPX/DocumentType.aspx/MigrateDocumentType", sXML);
            if (validateXMLResults(result))
            {
                var confirm;
                confirm = $(result).find("ConfirmObject>Row").eq(0);
                if (($(confirm) && $(confirm).attr("Success")).toString() === "1")
                {
                    //Now that the document has been created upload the actual file
                }
                else
                {
                    var retval;
                    top.SetPSCurrent("BodyText", $(confirm).attr("reasonFailed"));
                    top.SetPSCurrent("Caption", "Migration failed");
                    top.SetPSCurrent("ImageLabel", "Unable to migrate document type to the selected properties.");
                    retval = top.NavSuperModal('attention');
                    top.RemovePageState('BodyText');
                    top.RemovePageState('Caption');
                    top.RemovePageState('ImageLabel');
                }
            }
            else
            {
                top.NavErrorModal(getErrors(result));
            }

            window.returnValue = true;
            //window.close();
            top.hideDialog(window.returnValue, window, bUsingIframe);
        }

    </script>
</head>
<%call CreateImports("errorhandling")%>
<%call CreateImports("modalheader")%>
<%call CreateImports("supertable")%>
<body class="datamodal" tabindex="-1">
    <div class="RPI_MODALHEADER" id="mhead" pagetrail="Document Management " pagelabel="Migrate document type"
        pageid="101.090.020.020">
    </div>
    <span style="width: 100%;">Select the properties to push document type to.</span>
    <table cellpadding="0" cellspacing="0" border="0" id="headerTable">
        <tr>
            <td style="vertical-align: bottom; width: 340px; font-weight: bold; font-size: 10pt;">
                Properties
            </td>
        </tr>
    </table>
    <div class="RPI_SUPERTABLE" id="tblProperties" rpdatasource="#xmlProperties" rpdatanode="Properties"
        rpheader="true" rppagesize="7" rpwidth="420px" rpheight="200px" rpscroll="FALSE"
        rpheightlock="true" rpnodatamsg="This document type has not been migrated to any properties">
        <table border="1" style="display: none;">
            <thead>
                <tr style='height: 34px;'>
                    <th style="text-align: center; width: 32px;" class="center" rpsortable="false">
                        <input type="checkbox" id="chkSelectAll" name="chkSelectAll" rpclickaction="doToggleSelectAll()"
                            rprowselection="Multi" style="border: none; background-color: transparent;" title="Select or de-select all properties" />
                    </th>
                    <th id="effectiveDateCol" style="text-align: center;" class="center" rpsortby="Name">
                        Name
                    </th>
                </tr>
            </thead>
            <tbody>
                <tr>
                    <td style="text-align: center;" class="center">
                        <!--# if(@Selected === '1') { -->
                        <input type="checkbox" id="chkSelected" style="border: none; background-color: transparent;"
                            name="chkSelected" rpclickaction="doToggleSelected()" class="chkbox" checked="checked" />
                        <!--# } else { -->
                        <input type="checkbox" id="chkSelected" style="border: none; background-color: transparent;"
                            name="chkSelected" rpclickaction="doToggleSelected()" class="chkbox" />
                        <!--# } -->
                    </td>
                    <td rpdatafld="Name" style="text-align: left;" rpnowrap="true">
                    </td>
                </tr>
            </tbody>
        </table>
    </div>
    <table>
        <tr>
            <td id="applyCheckBox" style="vertical-align: middle;">
                <%Call Controls_CreateCheckbox("chkApplyToExistingDocs","chkApplyToExistingDocs","1","") %>&nbsp;<nobr>Apply retention settings changes to uploaded documents</nobr>
            </td>
        </tr>
    </table>
    <table>
        <tr>
            <td>
                <b>Important note :</b> Document type will be removed from the properties which
                are unchecked and also removed from all packet template(s).
            </td>
        </tr>
    </table>
    <div class="IFrameButtons">
    <table id="buttons" border="0">
        <tr>
            <td>
                <%call Controls_CreateButton("btnPush","Push","Push_Initialize()","1","","")%>
            </td>
            <td>
                <%call Controls_CreateButton("btnCancel","Cancel","doCancel()","1","","")%>
            </td>
        </tr>
    </table>
    </div>
    <!-- Code to know when binding is done. -->
    <input type="hidden" value="~" datasrc="#xmlControls_WATCH_Initialize" datafld="a"
        onpropertychange="this.onpropertychange='';afterBinding();" id="Hidden1" name="Hidden1" />
</body>
<script type="text/javascript">
    $(window).load(function ()
    {
        var otblProperties = "";
        InitialLoad_ScreenReady();
        InitialLoad_Start();
    });
    var oCBConverted = { 'ie': true, 'firefox': true, 'chrome': true, 'safari': true };         
</script>
</html>
